package com.ruoyi.web.wh.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.framework.aspectj.Log;
import com.ruoyi.framework.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.Result;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.web.wh.domain.WhGoodstype;
import com.ruoyi.web.wh.domain.WhPutInData;
import com.ruoyi.web.wh.domain.WhStorage;
import com.ruoyi.web.wh.domain.WhTypeData;
import com.ruoyi.web.wh.service.IWhGoodstypeService;
import com.ruoyi.web.wh.service.IWhRecordService;
import com.ruoyi.web.wh.service.IWhStorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 仓库Controller
 *
 * @author ruoyi
 * @date 2025-02-23
 */
@RestController
@RequestMapping("/wh/data")
public class WhDataController extends BaseController {
    @Autowired
    private IWhGoodstypeService whGoodsTypeService;

    @Autowired
    private IWhRecordService whRecordService;

    /**
     * 查询仓库列表
     */
    @SaCheckPermission("wh:storage:list")
    @GetMapping("/type")
    public Result list() {
        //查出所有物品分类
        List<WhTypeData> list = whGoodsTypeService.selectWhGoodTypeData();
        for (WhTypeData whTypeData : list) {
            if (whTypeData.getCount() == null) {
                whTypeData.setCount(0L);
            }
        }
        return success(list);
    }

    /**
     * 查询仓库列表
     */
    @SaCheckPermission("wh:storage:list")
    @GetMapping("/putInRank")
    public Result putInRank() {
        //入库排行
        List<WhPutInData> list = whRecordService.selectWhRecordInRank();
        return success(list);
    }

}
